﻿CREATE TABLE [dbo].[tblSequenceStep] (
    [SequenceStepID]     INT      IDENTITY (1, 1) NOT NULL,
    [SequenceID]         INT      NOT NULL,
    [SequenceOrderID]    INT      NULL,
    [Delay]              SMALLINT NOT NULL,
    [RecurrenceTerm]     SMALLINT NOT NULL,
    [RecurrenceCount]    SMALLINT NOT NULL,
    [RecurrenceCycle]    SMALLINT NOT NULL,
    [PrevSequenceStepID] INT      NULL,
	[SourceSequenceStepID] int	null,
	[CurrentCount]		int null,
	[NextTriggerDate]	smalldatetime null,
	[LastOrderID]	int	null
);


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'The number of days to delay from the previous step', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'tblSequenceStep', @level2type = N'COLUMN', @level2name = N'Delay';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'The number of days between recurrences of this step', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'tblSequenceStep', @level2type = N'COLUMN', @level2name = N'RecurrenceTerm';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'The number of times the step recurres before continuing to the next step.  Set to -1 if this step is to recur indefinately.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'tblSequenceStep', @level2type = N'COLUMN', @level2name = N'RecurrenceCount';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'The recurrence cycle that this step is currently in.', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'tblSequenceStep', @level2type = N'COLUMN', @level2name = N'RecurrenceCycle';


GO
EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'The ID of the next step', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'tblSequenceStep', @level2type = N'COLUMN', @level2name = N'PrevSequenceStepID';

